package swind.common.Excel;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import swind.web.exception.ExcelFormatException;
import swind.web.vo.TeaGetStudentVo;

public class ExcelUtils {
	
	 public static final String OFFICE_EXCEL_2003_POSTFIX = "xls";
	 public static final String OFFICE_EXCEL_2010_POSTFIX = "xlsx";
	
	
	public Workbook openWorkBook(InputStream in, String format) throws ExcelFormatException, IOException  {
		// TODO Auto-generated method stub
		Workbook book = null;
		
		if(format.equals(OFFICE_EXCEL_2003_POSTFIX)){
			book = new HSSFWorkbook(in);
			
		}else if(format.equals(OFFICE_EXCEL_2010_POSTFIX)){
			book = new XSSFWorkbook(in);
			
		}else{
			throw new ExcelFormatException();
		}
		
		return book;
	}
	
	
	
}
